import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: () => import('../views/Login')
  },
  {
    path: '/main',
    name: 'main',
    component: () => import('../views/Main'),
    children: [
      {
        name: 'welcome',
        path: '/welcome',
        component: () => import('../views/Welcome'),
        meta: {
          title: '欢迎页',
          requireAuth: true
        }
      },
      {
        name: 'personal_info',
        path: '/personal_info',
        component: () => import('../views/PersonalInfo'),
        meta: {
          title: '个人信息',
          requireAuth: true
        }
      },
      {
        name: 'personal_password',
        path: '/personal_password',
        component: () => import('../views/PersonalPassword'),
        meta: {
          title: '密码管理',
          requireAuth: true
        }
      },
      {
        name: 'user_add',
        path: '/user_add',
        component: () => import('../views/User/UserAdd'),
        meta: {
          title: '添加用户',
          requireAuth: true
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
